
#ifndef _APDU_LIB_RSA_MGR_H_
#define _APDU_LIB_RSA_MGR_H_

#include "../apdu.def/apdu_datatypes.h"


#ifdef __cplusplus
extern "C" {
#endif

	int app_gen_rsa_keypair(HANDLE devHandle, int app_id, int container_id, int modulus_len, 
						unsigned char * rsa_pub_key_blob, int blob_len);

	int app_gen_rsa_keypair_ex(HANDLE devHandle, int app_id, int container_id, int modulus_len, int key_spec,
						unsigned char * rsa_pub_key_blob, int blob_len);

	int app_import_rsa_keypair(HANDLE devHandle, int app_id, int container_id, unsigned long sym_alg_id, 
						unsigned char * wrapped_key, int wrapped_key_len, int bits, unsigned char * encrypted_data, 
						int encrypt_data_len);


	int app_rsa_sign_data(HANDLE devHandle, int app_id, int container_id, int input_mode, int hash_algo, 
						unsigned char * input_data, int data_len, unsigned char * signature, int *sig_len);

	int app_rsa_verify(HANDLE devHandle, int data_mode, int hash_algo, unsigned char * pub_key_blob, int key_blob_len, 
						unsigned char * input_data, int data_len, unsigned char * signature, int sig_len);

	
	int app_rsa_export_session_key( HANDLE devHandle, int app_id, int container_id, unsigned long alg_id,
						unsigned char * pub_key_blob, int key_blob_len, 
						int * session_key_id, unsigned char * encrypt_session_key, int *session_key_len);
	
	int app_rsa_export_session_key_ex(HANDLE devHandle, int app_id, int container_id, int session_key_id, 
						unsigned char * pub_key_blob, int key_blob_len, 
						unsigned char * encrypt_session_key, int * session_key_len);

	int app_rsa_ext_rsa_pubkey_operation(HANDLE devHandle, unsigned char * pub_key_blob, int key_blob_len, 
						unsigned char * input_data, int input_len, 
						unsigned char * output_data, int * output_len);

	int app_rsa_ext_rsa_encrypt(HANDLE devHandle, unsigned char * pub_key_blob, int key_blob_len, 
						unsigned char * input_data, int input_len, 
						unsigned char * output_data, int * output_len);

	int app_rsa_public(HANDLE devHandle, int app_id, int container_id, int key_spec,
						unsigned char * input_data, int input_len,
						unsigned char * output_data, int * output_len);

	int app_rsa_private(HANDLE devHandle, int app_id, int container_id, int key_spec,
						unsigned char * input_data, int input_len,
						unsigned char * output_data, int * output_len);

	int app_rsa_encrypt_pkcs1(HANDLE devHandle, int app_id, int container_id, int key_spec,
						unsigned char * plaint, int plaint_len,
						unsigned char * cipher, int * cipher_len);

	int app_rsa_decrypt_pkcs1(HANDLE devHandle, int app_id, int container_id, int key_spec,
						unsigned char * plaint, int plaint_len,
						unsigned char * cipher, int * cipher_len);
	
	int app_rsa_sign_ex(HANDLE devHandle, int app_id, int container_id, int key_spec, 
						int hash_algo, unsigned char * input, int input_len,
						unsigned char * signature, int *sig_len);
	
	int app_rsa_sign_data_interactive(HANDLE devHandle, int app_id, int container_id, int key_spec, int hash_algo,int timeout,
						unsigned char * input,  int input_len, 
						unsigned char * signature, int *sig_len);

	int app_rsa_sign_data_interactive_cancel(HANDLE devHandle, int app_id, int container_id, int key_spec, int hash_algo);


	int app_rsa_verify_ex(HANDLE devHandle, int app_id, int container_id, int key_spec,
						int hash_algo, unsigned char * data, int data_len, 
						unsigned char * signature, int sig_len);

	int app_import_ext_rsa_keypair(HANDLE devHandle,int app_id, int container_id, int key_spec,
						unsigned char * prikey_blob, int blob_len);

	int app_gen_ext_rsa_keypair(HANDLE devHandle, int bits, unsigned char * prikey_blob, int * blob_len);

	int app_export_ext_rsa_pubkey(HANDLE devHandle, unsigned char * pubkey_blob, int * blob_len);

	int app_import_ext_rsa_keypair_to_ram(HANDLE devHandle, int is_last, unsigned char * key_blob, int blob_len);

	int app_ram_rsa_public(HANDLE devHandle, unsigned char * input, int input_len, unsigned char * output, int * output_len);

	int app_ram_rsa_private(HANDLE devHandle, unsigned char * input, int input_len, unsigned char * output, int * output_len);
#ifdef __cplusplus
}
#endif

#endif
